﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.IO;
using HK.Reports;

namespace userHK_grid
{
    
    public partial class FormGRID : Form
    {
        grid_class gc;

        public FormGRID()
        {
            InitializeComponent(); 
        }
        public FormGRID(DataTable dt)
            : this()
        {
            gc = new grid_class(
                dt, 
                dataGridView1, 
                toolStripComboBox1, 
                toolStripComboBox2, 
                toolStripStatusLabel2,
                toolStripTextBox1);
        }
        public FormGRID(string SQL, string shema, string server)
            : this()
        {
            gc = new grid_class(
                SQL, 
                shema, 
                server,
                dataGridView1,
                toolStripComboBox1,
                toolStripComboBox2,
                toolStripStatusLabel2,
                toolStripTextBox1);
        }
        public FormGRID(string SQL, string shema, string server, string reportName, string tableName)
            : this()
        {
            gc = new grid_class(
                SQL, 
                shema, 
                server, 
                reportName,
                tableName,
                dataGridView1,
                toolStripComboBox1,
                toolStripComboBox2,
                toolStripStatusLabel2,
                toolStripTextBox1);
        }
        public FormGRID(string SQL, string shema, string server, string reportName, string tableName, string reportHead, string reportItog)
            : this()
        {
            gc = new grid_class(
                SQL, 
                shema, 
                server,
                reportName,
                tableName,
                reportHead, 
                reportItog,
                dataGridView1,
                toolStripComboBox1,
                toolStripComboBox2,
                toolStripStatusLabel2,
                toolStripTextBox1);
        }
        public FormGRID(string SQL, string shema, string server, string reportName, string tableName, string reportHead, string reportItog, bool land)
            : this()
        {
            gc = new grid_class(
                SQL, 
                shema, 
                server,
                reportName,
                tableName,
                reportHead, 
                reportItog, 
                land,
                dataGridView1,
                toolStripComboBox1,
                toolStripComboBox2,
                toolStripStatusLabel2,
                toolStripTextBox1);
        }
        public FormGRID(string SQL, string shema, string server, string reportName, string tableName, string reportHead, string reportItog, bool land, string editColumns)
            : this()
        {
            gc = new grid_class(
                SQL, 
                shema, 
                server,
                reportName,
                tableName,
                reportHead, 
                reportItog, 
                land, 
                editColumns,
                dataGridView1,
                toolStripComboBox1,
                toolStripComboBox2,
                toolStripStatusLabel2,
                toolStripTextBox1);
        }
        public FormGRID(DataView dv)
            : this()
        {
            gc = new grid_class(
                dv,
                dataGridView1,
                toolStripComboBox1,
                toolStripComboBox2,
                toolStripStatusLabel2,
                toolStripTextBox1);
        }

        #region events
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            gc.saveDataXML();
            MessageBox.Show("Изменения сохранены успешно.");
        } 
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
           gc.toolStripMenuItem2_Click_fun(sender, e);        
        }
        private void toolStripMenuItem1_MouseEnter(object sender, EventArgs e)
        {
           gc.setTSMI("Сохранить параметры формы");
        }
        private void toolStripMenuItem1_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripMenuItem2_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Експорт содержимого в Excel");
        }
        private void toolStripMenuItem2_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            gc.toolStripMenuItem3_Click_fun();       
        }
        private void toolStripMenuItem3_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Параметры шрифта");
        }
        private void toolStripMenuItem3_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            gc.toolStripMenuItem4_Click_fun(sender, e);      
        }
        private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
            gc.toolStripMenuItem5_Click_fun(sender, e);       
        }
        private void toolStripMenuItem6_Click(object sender, EventArgs e)
        {
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullColumnSelect;
        }
        private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {

        }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {

        }
        private void toolStripMenuItem7_Click(object sender, EventArgs e)
        {
        }
        private void toolStripMenuItem7_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Авторазмер столбцов");
        }
        private void toolStripMenuItem7_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripMenuItem4_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Увеличить масштаб");
        }
        private void toolStripMenuItem4_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripMenuItem5_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Уменьшить масштаб");
        }
        private void toolStripMenuItem5_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripMenuItem6_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Режим выделения - по столбцам");
        }
        private void toolStripMenuItem6_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripTextBox1_TextChanged(object sender, EventArgs e)
        {

        }
        private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
        {

        }
        private void toolStripMenuItem6_Click_1(object sender, EventArgs e)
        {
            gc.setMode(FAED.edit_col);
        }
        private void toolStripMenuItem8_Click(object sender, EventArgs e)
        {
            gc.setMode(FAED.look_row);
        }
        private void toolStripMenuItem9_Click(object sender, EventArgs e)
        {
            gc.setMode(FAED.look_cell);
        }
        private void toolStripTextBox1_Click(object sender, EventArgs e)
        {

        }
        private void toolStripMenuItem9_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Режим просмотра таблицы");
        }
        private void toolStripMenuItem9_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripMenuItem6_MouseEnter_1(object sender, EventArgs e)
        {
            gc.setTSMI("Режим редактирования наименований колонок");
        }
        private void toolStripMenuItem6_MouseLeave_1(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void dataGridView1_Click(object sender, EventArgs e)
        {
            gc.cellclick();
        }
        private void toolStripMenuItem8_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Режим выделения строк");
        }
        private void toolStripMenuItem8_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripMenuItem11_Click(object sender, EventArgs e)
        {
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
        }
        private void toolStripMenuItem12_Click(object sender, EventArgs e)
        {
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader;
        }
        private void toolStripMenuItem13_Click(object sender, EventArgs e)
        {
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
        private void toolStripMenuItem14_Click(object sender, EventArgs e)
        {
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
        private void toolStripMenuItem15_Click(object sender, EventArgs e)
        {
            gc.querySQL(); 
        }
        private void toolStripMenuItem15_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Написать SQL запрос");
        }
        private void toolStripMenuItem15_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (gc!=null ) gc.toolStripComboBox1_SelectedIndexChanged_fun();
        }
        private void toolStripTextBox1_KeyUp(object sender, KeyEventArgs e)
        {
            gc.toolStripTextBox1_KeyUp_fun(e);    
        }
        private void toolStripMenuItem16_Click(object sender, EventArgs e)
        {
            gc.printTable();
        }
        private void toolStripMenuItem17_Click(object sender, EventArgs e)
        {
            //chekXML();
        }
        private void toolStripComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(gc!=null ) 
                gc.toolStripComboBox2_SelectedIndexChanged_fun();     
        }
        private void toolStripMenuItem16_MouseEnter(object sender, EventArgs e)
        {
            gc.setTSMI("Печать");
        }
        private void toolStripMenuItem16_MouseLeave(object sender, EventArgs e)
        {
            gc.setTSMI("");
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
        private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {

        }
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            //gc.celledit();
        }
        private void toolStripMenuItem18_Click(object sender, EventArgs e)
        {
            gc.toolStripMenuItem18_Click_fun();        
        }
        private void toolStripMenuItem19_Click(object sender, EventArgs e)
        {
            gc.toolStripMenuItem19_Click_fun();
        }
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            gc.deleterow();
        }
        private void toolStripMenuItem20_Click(object sender, EventArgs e)
        {
            gc.toolStripMenuItem20_Click_fun();
        }
        private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            //addrow();
        }
        private void dataGridView1_UserAddedRow(object sender, DataGridViewRowEventArgs e)
        {
            //addrow();
        }
        private void dataGridView1_NewRowNeeded(object sender, DataGridViewRowEventArgs e)
        {
            //addrow();
        }
        private void dataGridView1_RowLeave(object sender, DataGridViewCellEventArgs e)
        {
            gc.addrow();
        }
        #endregion

        private void toolStripComboBox2_Click(object sender, EventArgs e)
        {

        }

      
        
        

        

    }
}

